import { createStore } from 'vuex'

export default createStore({
  state: {
    count: 12
  },
  mutations: {
    add (state, step: number) {
      state.count++
      console.log('state: ', state.count, 'step: ', step)
    }
  },
  actions: {
    addSync ({ commit }, step: any) {
      setTimeout(() => {
        commit('step', step)
      }, 1000)
    }
    // 二：
    // addSync (context, step: number) {
    //   setTimeout(() => {
    //     context.commit('step', step)
    //   },1000)
    // }

  },
  getters: {
    getStateValue (state) {
      return state.count * 2
    }
  },
  modules: {
  }
})
